package fr.enseirbmatmeca.apms.spring.service;

import java.util.List;

import org.springframework.transaction.annotation.Transactional;

import fr.enseirbmatmeca.apms.spring.model.project.Project;
import fr.enseirbmatmeca.apms.spring.model.user.User;
import fr.enseirbmatmeca.apms.spring.security.ProjectRole;

/**
 * This interface publishes features to handler users
 * @author coudar
 */

public interface UserManager {

	/**
	 * Change the password to 'password' for the given login
	 * @param login : user login
	 * @param password : user new password
	 * @return the new User object
	 */
	@Transactional (readOnly=false)
	public String changePassword (String login, String password);
	/**
	 * Check if the login exists and if the password is correct. 
	 * @param login : user login
	 * @param password : user password
	 * @return true if the login exists and if the password is correct. 
	 * Otherwise, return false. 
	 */
	public boolean checkLogin (String login, String password);
	@Transactional (readOnly=false)
	public String createUser(User user);
	
	@Transactional(readOnly = false)
	public User createUser(String login, String password);
	
	@Transactional (readOnly=false)
	public String delete(User user);
	
	public List<User> findAll();
	
	@Transactional(readOnly = false)
	public boolean saveUser(User user);
	
	/**
	 * Return a User object from a given login.
	 * @param login : user login
	 * @return the corresponding user object.
	 */
	public User getUser(String login);
	
	@Transactional (readOnly=false)
	public String update(User user);

	public List<ProjectRole> getProjectRoles(User user, Project project);
	
}
